"""方法"""
from typing import Any, Dict  # 类型注解库，提升代码阅读性
import binascii  # 处理二进制和ASCII之间的转换库


class Car:
    def __init__(self, brand: str, fuel_type: str) -> None:
        self.brand = brand
        self.fuel_type = fuel_type

    def drive(self, distance: float) -> None:
        print(f"driving {self.brand} for {distance}km [{self.fuel_type}]")


volvo: Car = Car(brand='Volvo', fuel_type='Diesel')
bmw: Car = Car(brand='BMW', fuel_type='electric')

print(volvo.brand)
print(bmw.brand)
print(bmw.fuel_type)
bmw.drive(distance=10)


class DataOperation:
    """数据操作，包括字典、字符串、"""

    @staticmethod
    def str_operation():
        # 定义list序列
        str_list = [1, 2, 3, '213']
        print(type(str_list))

    @staticmethod
    def str_to_hex():
        """将字符串转换成十六进制"""
        # 定义字符串,先转换成字节
        string_data = 'AB,C,121'.encode('utf-8')
        # 再转换成十六进制
        str_to_hex = string_data.hex()
        print(f"这是转换后的hex{str_to_hex}")

    @staticmethod
    def dict_operation():
        create_list = [1, 2, 3, 4]
        print(type(create_list))
        create_set = {1, 2, 3, 4}
        create_dict = {"12": "12", "12": 12}  # 重复的键值自动修复成{"12":"12"}
        create_dict2 = {"12":None,"12":None}
        create_list2 = [{"key": "value"}]

        #
        print(type(create_dict2))
        print(type(create_set))
        print(type(create_dict))
        print(type(create_list2))


    @staticmethod
    def hex_to_str():
        """将十六进制转换成string"""
        str_list = [1, 2, 3, '123']
        # 转换成字符串
        data = str_list


user_count: int


class PositionArguments:
    """熟悉args Position Arguments 和 keyword Arguments参数的使用"""

    def sum(*args: Any) -> None:
        """"""
        total = 0


class CodeAnnotation:
    """注解的使用"""


class User:
    def __init__(self, name: str, age: int):
        self.name = name
        self.age = age


def create_user(name: str, age: int) -> User:
    return User(name, age)


if __name__ == '__main__':
    DataOperation.str_to_hex()
    DataOperation.str_operation()
    DataOperation.dict_operation()
    create_user('jack', 18)
